﻿using NthDownload.Common.ViewModels;
using NthDownload.Contracts;

namespace NthDownload.DownloadPlugins.Http.ViewModels
{
    public class HttpCredentialsDetailsViewModel : ViewModelScreenBase
    {
        #region Class Members

        private HttpCredentials _credentials;

        #endregion Class Members

        #region Constructors

        public HttpCredentialsDetailsViewModel(HttpCredentials credentials)
        {
            //
            // Set Defaults
            //
            Credentials = credentials;
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// The credentials who's details are being shown
        /// </summary>
        public HttpCredentials Credentials
        {
            get
            {
                return _credentials;
            }
            set
            {
                _credentials = value;
                NotifyOfPropertyChange(() => Credentials);
            }
        }

        #endregion Properties

        #region Methods

        /// <summary>
        /// Closes the dialog with a save result
        /// </summary>
        public void Save()
        {
            if (!BindingGroupValidator.ValidateBindingExpressionsWithUpdate())
            {
                return;
            }

            Result = ViewModelResults.Save;
            TryClose();
        }

        /// <summary>
        /// Closes the dialog with a save result
        /// </summary>
        public void Cancel()
        {
            Result = ViewModelResults.Cancel;
            TryClose();
        }

        #endregion Methods
    }
}
